SRC_DIR = .
BUILD_DIR = build

PREFIX = .
DOCS_DIR = ${PREFIX}/docs
DIST_DIR = ${PREFIX}/dist

BASE_FILES = ${SRC_DIR}/jquery.layout.js

MODULES = ${BASE_FILES}

JQ = ${DIST_DIR}/jquery.layout.js
JQ_MIN = ${DIST_DIR}/jquery.layout.min.js
JQ_PACK = ${DIST_DIR}/jquery.layout.pack.js

JQ_VER = `cat version.txt`
VER = sed s/@VERSION/${JQ_VER}/

JAR = java -jar ${BUILD_DIR}/js.jar

# disabled packing for a while
#all: borderlayout min pack
all: borderlayout min
	@@echo "jQuery Border Layout build complete."

${DIST_DIR}:
	@@mkdir -p ${DIST_DIR}

borderlayout: ${DIST_DIR} ${JQ}

${JQ}: ${MODULES}
	@@echo "Building" ${JQ}

	@@mkdir -p ${DIST_DIR}
	@@cat ${MODULES} | ${VER} > ${JQ};

	@@echo ${JQ} "Built"
	@@echo

pack: ${JQ_PACK}

${JQ_PACK}: ${JQ}
	@@echo "Building" ${JQ_PACK}

	@@echo " - Compressing using Packer"
	@@${JAR} ${BUILD_DIR}/build/pack.js ${JQ} ${JQ_PACK}

	@@echo ${JQ_PACK} "Built"
	@@echo

min: ${JQ_MIN}

${JQ_MIN}: ${JQ}
	@@echo "Building" ${JQ_MIN}

	@@echo " - Compressing using Minifier"
	@@${JAR} ${BUILD_DIR}/build/min.js ${JQ} ${JQ_MIN}

	@@echo ${JQ_MIN} "Built"
	@@echo

clean:
	@@echo "Removing Distribution directory:" ${DIST_DIR}
	@@rm ${DIST_DIR}/*